Development Guide
Setup
# Clone repository
git clone https://github.com/Quig-Enterprises/cyber-guardian.git
cd cyber-guardian
# Install dependencies
pip install -e '.[dev]'
# Copy and configure
cp config.yaml config.local.yaml
# Edit config.local.yaml with your settings
# Set environment variables
export DB_PASSWORD="your-db-password"
export REDTEAM_SYSADMIN_PASS="test-password"
Running Tests
# All tests
pytest
# Specific category
pytest tests/test_ai_attacks.py
pytest tests/test_api_attacks.py
# With coverage
pytest --cov=cyberguardian --cov-report=html
Project Structure
cyber-guardian/
βββ cyberguardian/ # CLI package
β βββ __init__.py
β βββ cli.py # Main entry point
β
βββ redteam/ # Red Team (Offensive)
β βββ attacks/ # Attack modules
β βββ evaluators/ # Result evaluators
β βββ reporters/ # Report generators
β βββ cleanup/ # Artifact cleanup
β
βββ blueteam/ # Blue Team (Defensive)
β βββ collectors/ # Log/event collectors
β βββ correlator/ # Event correlation
β βββ alerting/ # Alert engine
β βββ compliance/ # Compliance tracking
β βββ incident/ # Incident response
β βββ reports/ # Compliance reports
β
βββ shared/ # Common infrastructure
β βββ auth.py # Authentication client
β βββ database.py # Database utilities
β βββ config.py # Config loader
β
βββ docs/ # Documentation
βββ tests/ # Integration tests
βββ reports/ # Generated reports
Adding a New Attack Module
- Create attack file in
redteam/attacks/{category}/ - Inherit from
Attackbase class - Implement
execute()andevaluate()methods - Add to registry by importing in
redteam/attacks/{category}/__init__.py
Example:
from redteam.base import Attack, AttackResult
class NewAttack(Attack):
name = "category.new_attack"
category = "ai"
severity = "high"
description = "Description of attack"
async def execute(self, client):
# Run attack
response = await client.post("/api/endpoint", json={...})
return [AttackResult(
attack_name=self.name,
variant="variant1",
status="vulnerable" if success else "defended",
severity=self.severity,
evidence=response.text,
details="Explanation",
request={...},
response={...},
duration_ms=elapsed
)]
def evaluate(self, result):
# Score the result
pass
Adding a Blue Team Collector
- Create collector file in
blueteam/collectors/ - Inherit from
Collectorbase class - Implement
collect()method - Register in
blueteam/collectors/__init__.py
Code Style
- Black for formatting (line length 100)
- Ruff for linting
- Type hints for all public functions
- Docstrings for all classes and public methods
Run formatters:
black .
ruff check --fix .
Git Workflow
- Create feature branch from
main - Make changes
- Run tests
- Commit with descriptive message
- Push and create PR
Versioning
- Major (X.0.0): Breaking changes, new architecture
- Minor (1.X.0): New features, attack modules, collectors
- Patch (1.0.X): Bug fixes, documentation
Update version in:
- pyproject.toml
- cyberguardian/__init__.py
- README.md
Release Process
- Update version numbers
- Update CHANGELOG.md
- Tag release:
git tag v1.0.0 - Push tags:
git push --tags - GitHub Actions will build and publish